import axios from "axios";

//初始化axios实例
var instance = axios.create({
    baseURL: 'http://124.239.132.135:8455',
    timeout: 20000,
  });

  //将token信息，添加到请求头
  export const $setToken = (token)=>{
    instance.defaults.headers.common['token'] = token;
  }
  //get方法
  export const $get = async(url,params)=>{
    let {data} =await instance.get(url,{
        params
    })
    return data
  }
  //post方法
  // export const $post = async(url,params)=>{
  //   let {data} = await instance.post(url,params)
  //   return data
  // }
  export const $post = async(url,params)=>{
    let {data} = await instance.post(url,params)
    return data
  }
  //put方法
  export const $put = async(url,params)=>{
    let {data} = await instance.put(url,params)
    return data
  }
  //delete方法
  export const $delete = async(url,params)=>{
    let {data} =await instance.delete(url,{
        params
    })
    return data
  }